<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript">
	$(function(){
		$("tr:even").css("backgroundColor","#9f9f9f");
	});
	function dele(id){
		if (confirm("确认删除这本书嘛?")) {
			$.get("DeleServlet","id="+id,function(data){
				if (data>0) {
					alert("删除成功!");
					window.location.href="ListServlet";
				}else{
					alert("删除失败!");
				}
			});
		}else{
			alert("你取消了删除!");
		}
	}
</script>
</head>
<body>
	<div style="width: 400px;margin: 0 auto;">
		<h1 align="center">图书信息</h1>
		<table border="1">
			<tr>
				<th>图书名称</th>
				<th>图书作者</th>
				<th>购买时间</th>
				<th>图书分类</th>
				<th>操作</th>
			</tr>
			<c:forEach var="book" items="${requestScope.list }">
			<tr>
				<td>${book.name }</td>
				<td>${book.author }</td>
				<td>${book.time }</td>
				<td>
				<c:if test="${book.type ==1 }">计算机/软件</c:if>
				<c:if test="${book.type ==2 }">小说/文稿</c:if>
				<c:if test="${book.type ==3 }">杂项</c:if>
				</td>
				<td><a href="javascript:dele(${book.id })" style="text-decoration: none;" >删除</a></td>
			</tr>
			</c:forEach>
		</table>
		<p><a href="Add.jsp" style="color:red;text-decoration: none;">新增图书信息</a></p>
	</div>
</body>
</html>